package top.hjcwzx.wrench.trigger;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.hjcwzx.wrench.mqtt.service.publish.MqttPublisher;

/**
 *
 * <p><b>类名：</b> MqttController</p>
 * <p><b>描述：</b> 消费</p>
 * <p><b>创建时间：</b> 2025-06-17 16:02 </p>
 *
 * @author 胡锦程
 */
@RestController
@RequestMapping("/mqtt")
public class MqttController {

    @Autowired
    private MqttPublisher<String> mqttPublisher;

    @GetMapping("/publish")
    public String publish(String topic) throws MqttException, JsonProcessingException {
        mqttPublisher.publish(topic, "你还哦");
        return "发布成功";
    }

}
